﻿<navigation:Page x:Class="QSHC.QSchedule.Silverlight.Views.PhysicianSchedulePage" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:vm="clr-namespace:QSHC.QSchedule.Silverlight.ViewModels"
           xmlns:converter="clr-namespace:QSHC.QSchedule.Silverlight.Converters"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="800" d:DesignHeight="600"
           Title="PhysicianSchedulePage" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
    
    <navigation:Page.Resources>
        <vm:PhysicianScheduleViewModel x:Key="physicianScheduleViewModel" />
        <converter:PhysicianToTextConverter x:Key="physicianToTextConverter" />
        <converter:DayOfWeekConverter x:Key="dayOfWeekConverter" />
        <converter:PhysicianScheduleDateConverter x:Key="physicianScheduleDateConverter" />
    </navigation:Page.Resources>
    
    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource physicianScheduleViewModel}}">
        <StackPanel Orientation="Horizontal">
            <ListBox Width="250" Margin="5" Style="{StaticResource ListBoxStyle}" ItemsSource="{Binding Path=Physicians}" SelectedItem="{Binding Path=SelectedPhysician, Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding EmployeeCode, Converter={StaticResource physicianToTextConverter}}" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <StackPanel Orientation="Vertical">
                <sdk:DataGrid Margin="5" AutoGenerateColumns="False" Height="400" Width="700" ItemsSource="{Binding Path=PhysicianSchedules}" SelectedItem="{Binding Path=SelectedPhysicianSchedule, Mode=TwoWay}" FontFamily="Tahoma" FontSize="14">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Binding="{Binding Path=Service.Name}" Header="หน่วยบริการ" IsReadOnly="True" />
                        <sdk:DataGridTextColumn Binding="{Binding Path=DayOfWeek, Converter={StaticResource dayOfWeekConverter}}" Header="วัน" IsReadOnly="True" />
                        <sdk:DataGridTextColumn Binding="{Binding Path=Quota}" Header="โควต้า" IsReadOnly="True" />
                        <sdk:DataGridTextColumn Binding="{Binding Converter={StaticResource physicianScheduleDateConverter}}" Header="ตั้งแต่" IsReadOnly="True" />
                        <sdk:DataGridTextColumn Binding="{Binding Path=LastEmployeeLog}" Header="User" IsReadOnly="True" />
                        <sdk:DataGridTextColumn Binding="{Binding Path=LastLog.LogDateTime}" Header="Update" IsReadOnly="True" />
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
                <StackPanel Orientation="Horizontal">
                    <Button Content="เพิ่ม" Width="75" Margin="5" Style="{StaticResource ButtonStyle}" Command="{Binding Path=AddCommand}" />
                    <Button Content="แก้ไข" Width="75" Margin="5" Style="{StaticResource ButtonStyle}" Command="{Binding Path=EditCommand}" />
                    <Button Content="ลบ" Width="75" Margin="5" Style="{StaticResource ButtonStyle}" Command="{Binding Path=DeleteCommand}" />
                </StackPanel>
            </StackPanel>
        </StackPanel>
    </Grid>
</navigation:Page>
